class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        fun = dict()
        flag = set()
        for i in range(len(s)):
            if s[i] not in fun:
                if t[i] in flag:
                    return False
                fun[s[i]] = t[i]
                flag.add(t[i])
            else:
                if t[i] != fun[s[i]]:
                    return False
        else:
            return True
